import React, { useState, useEffect } from "react";
import { useSearchParams, useNavigate, Link } from "react-router-dom";
import SearchNav from "../../components/SearchNav/SearchNav";
import './read.css'
function BookRead(props) {
   let [searchParams, setSearchParams] = useSearchParams();
   let [content, setContent] = useState(null);

   let bookId = searchParams.get("bookId");
   let chapterId = searchParams.get("chapterId");
   console.log('bookId,chapterId----', bookId, chapterId);
   useEffect(() => {
      React.axios
         .get("reader/book/content.json", {
            params: { source_uuid: bookId, content_uuid: chapterId },
         })
         .then(function (res) {
            console.log(res);
            setContent(res.content);
         })
         .catch(function (error) {
            console.log(error);
         });
   }, [bookId, chapterId]);

   return (
      <div>
         <SearchNav/>
         <div className="rbook_read">
            <div dangerouslySetInnerHTML={{ __html: content }}></div>
            {/* <div className="control" style={{ width: "100vw", position: "fixed", bottom: 0, backgroundColor: "lightblue" }}>
               <button>上一章</button>
               <button>下一章</button>
            </div> */}
         </div>
      </div>
   );
}

export default BookRead;